<?php

require_once dirname(__FILE__).'/../lib/listracliGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/listracliGeneratorHelper.class.php';

/**
 * listracli actions.
 *
 * @package    laboratorio
 * @subpackage listracli
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class listracliActions extends autoListracliActions
{
  public function executeListImprimir(sfWebRequest $request){
    $filtro = new DetalleTrabajoFormFilter();
    $consulta = $filtro->buildQuery($this->getFilters());    
    $consulta->leftJoin('r.Trabajo t');
    $lista = $consulta->execute();
    
    $dompdf = new DOMPDF();
    $dompdf->load_html($this->getPartial("imprimir", array("trabajos" => $lista)));
    $dompdf->set_paper('A4','portrait');
    $dompdf->render();
    $dompdf->stream("listado.pdf");    
    return sfView::NONE;
  }
  
  public function executeFilter(sfWebRequest $request)
  {
    $this->setPage(1);

    if ($request->hasParameter('_reset'))
    {
      $this->setFilters($this->configuration->getFilterDefaults());

      $this->redirect('@trabajo_listracli');
    }

    $this->filters = $this->configuration->getFilterForm($this->getFilters());

    $this->filters->bind($request->getParameter($this->filters->getName()));
    if ($this->filters->isValid())
    {
      $this->setFilters($this->filters->getValues());
      $this->hasFilters = $this->getUser()->getAttribute('listracli.filters', $this->configuration->getFilterDefaults(), 'admin_module');

      //$this->redirect('@trabajo_listracli');
    }

    $this->pager = $this->getPager();
    $this->sort = $this->getSort();

    //$this->setTemplate('index');
  }
}
